package cn.iocoder.yudao.module.system.controller.admin.userassetscode.vo;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;

import java.time.LocalDateTime;
import java.util.List;

/**
 * 用户资源兑换码详细响应 VO
 * 包含使用者信息和留存率数据
 *
 * @author 系统
 */
@Schema(description = "管理后台 - 用户资源兑换码详细响应 VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class UserAssetsCodeDetailRespVO extends UserAssetsCodeRespVO {

    @Schema(description = "使用者信息列表")
    private List<UserInfo> userInfoList;

    @Schema(description = "留存率统计")
    private RetentionStats retentionStats;

    @Schema(description = "使用统计")
    private UsageStats usageStats;

    /**
     * 使用者信息
     */
    @Data
    @Schema(description = "使用者信息")
    public static class UserInfo {
        
        @Schema(description = "用户ID", example = "1024")
        private Long userId;
        
        @Schema(description = "用户名", example = "张三")
        private String username;
        
        @Schema(description = "昵称", example = "小张")
        private String nickname;
        
        @Schema(description = "手机号", example = "13888888888")
        private String mobile;
        
        @Schema(description = "邮箱", example = "zhang@example.com")
        private String email;
        
        @Schema(description = "使用时间")
        private LocalDateTime usageTime;
        
        @Schema(description = "使用者IP", example = "192.168.1.1")
        private String userIp;
        
        @Schema(description = "使用结果", example = "SUCCESS")
        private String usageResult;
        
        @Schema(description = "获得的资源信息", example = "专业版次数+10")
        private String resourceInfo;
        
        @Schema(description = "3日留存", example = "true")
        private Boolean retention3Days;
        
        @Schema(description = "7日留存", example = "true")
        private Boolean retention7Days;
        
        @Schema(description = "15日留存", example = "false")
        private Boolean retention15Days;
        
        @Schema(description = "总登录天数", example = "5")
        private Integer totalLoginDays;
        
        @Schema(description = "连续登录天数", example = "3")
        private Integer consecutiveLoginDays;
    }

    /**
     * 留存率统计
     */
    @Data
    @Schema(description = "留存率统计")
    public static class RetentionStats {
        
        @Schema(description = "总使用人数", example = "100")
        private Long totalUsers;
        
        @Schema(description = "3日留存人数", example = "80")
        private Long retention3DayUsers;
        
        @Schema(description = "7日留存人数", example = "60")
        private Long retention7DayUsers;
        
        @Schema(description = "15日留存人数", example = "40")
        private Long retention15DayUsers;
        
        @Schema(description = "3日留存率", example = "80.0")
        private Double retention3DayRate;
        
        @Schema(description = "7日留存率", example = "60.0")
        private Double retention7DayRate;
        
        @Schema(description = "15日留存率", example = "40.0")
        private Double retention15DayRate;
        
        @Schema(description = "平均登录天数", example = "4.5")
        private Double averageLoginDays;
        
        @Schema(description = "活跃用户数", example = "70")
        private Long activeUsers;
        
        @Schema(description = "流失用户数", example = "30")
        private Long churnUsers;
    }

    /**
     * 使用统计
     */
    @Data
    @Schema(description = "使用统计")
    public static class UsageStats {
        
        @Schema(description = "总使用次数", example = "150")
        private Long totalUsageCount;
        
        @Schema(description = "成功使用次数", example = "145")
        private Long successUsageCount;
        
        @Schema(description = "失败使用次数", example = "5")
        private Long failedUsageCount;
        
        @Schema(description = "成功率", example = "96.67")
        private Double successRate;
        
        @Schema(description = "最近使用时间")
        private LocalDateTime lastUsageTime;
        
        @Schema(description = "首次使用时间")
        private LocalDateTime firstUsageTime;
        
        @Schema(description = "平均每日使用次数", example = "2.5")
        private Double averageDailyUsage;
    }
}